package com.pig4cloud.pig.itinerary.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.itinerary.api.entity.TrItineraryContent;
import com.pig4cloud.pig.itinerary.service.TrItineraryContentService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/itineraryContent")
@Tag(description = "itineraryContent", name = "行程库内容管理")
public class TrItineraryContentController {
	private final TrItineraryContentService trItineraryContentService;
	/**
	 * 根据行程库id查询行程库内容 内容是一个集合
	 */
	@GetMapping("/getItineraryContentByItineraryId")
	public R<List<TrItineraryContent>> getByTripId(@RequestParam Long itineraryId) {
		// 参数校验
		if (itineraryId == null) {
			System.out.println("行程单不能为空");
		}
		List<TrItineraryContent> itineraryContentList = trItineraryContentService.list(
				Wrappers.<TrItineraryContent>lambdaQuery()
						.eq(TrItineraryContent::getItineraryId, itineraryId)
						.eq(TrItineraryContent::getDelFlag, 0) // 假设0表示未删除
		);
		// 返回结果
		return R.ok(itineraryContentList);
	}
}
